
using System;

using Gtk;

using stefc.geo.data;
using stefc.geo.data.model;


namespace MyLocate.dlg
{

	public partial class PreferencesDialog : Gtk.Dialog
	{
		public static bool Edit()
		{
			bool result=false;
			using(PreferencesDialog dlg = new PreferencesDialog())
			{	
				Configuration config = Configuration.Instance;
				
				dlg.comboboxUnit.Active = config.IsMetric ? 0 : 1;
				dlg.entryJId.Text = config.JId;
				dlg.entryPassword.Text = config.Password;
				
				if((ResponseType)dlg.Run()==ResponseType.Ok)
				{
					config.IsMetric = dlg.comboboxUnit.Active == 0;
					config.JId = dlg.entryJId.Text.Trim();
					config.Password = dlg.entryPassword.Text.Trim();
					result=true;
				}
				dlg.Destroy();
			}
			return result;
		}

		public PreferencesDialog ()
		{
			this.Build ();
		}
	}
}
